/**
 * @FileName NonterminalExpression.java
 * @Package com.designMode.interpreter
 * -------------------------------------
 * @function Please write description of function
 * @Date 2016-1-19 下午2:58:41
 * -------------------------------------
 * Copyright (c) 2016,顾博君 All Rights Reserved.
 */
package com.designMode.interpreter;

/**
 * @author 顾博君
 * @ClassName NonterminalExpression
 * @Date 2016-1-19 下午2:58:41
 * @Function 非终结符表达式
 */
public abstract class NonterminalExpression extends AbstractExpression {
    /**
     * 校验表达式结果是否是Boolean类型
     *
     * @param result 表达式结果
     * @param expStr 表达式
     * @throws IllegalArgumentException
     */
    public void checkBoolean(Object result, String expStr) throws IllegalArgumentException {
        if (!(result instanceof Boolean)) {
            throw new IllegalArgumentException("表达式" + expStr + "参数类型错误,参数类型应为：Boolean");
        }
    }
    /**
     * 校验表达式结果是否是Integer类型
     *
     * @param result 表达式结果
     * @param expStr 表达式
     * @throws IllegalArgumentException
     */
    public void checkInteger(Object result, String expStr) throws IllegalArgumentException {
        if (!(result instanceof Integer)) {
            throw new IllegalArgumentException("表达式" + expStr + "参数类型错误,参数类型应为：Integer");
        }
    }
}
